package com.foreknow.demo2;

import java.util.Scanner;

public class ControllDoWhile {
    public static void main(String[] args) {
        System.out.println("请输入消费金额");
        Scanner inputMoney = new Scanner(System.in);
        int userMoney = inputMoney.nextInt();
        boolean isRepeat = true;
        if (userMoney < 50) {
            System.out.println("非常遗憾您购物未满50元，不能参加此次活动");
        }else {
            do {
                    boolean isAc = true;
                    System.out.println("1.满50元 加2就可以换购产品A");
                    System.out.println("2.满100元 加3就可以换购产品B");
                    System.out.println("3.满100元 加10就可以换购产品C");
                    System.out.println("4.满200元 加10就可以换购产品D");
                    System.out.println("5.满200元 加20就可以换购产品E");
                    System.out.println("请选择参加几号活动");
                    Scanner acNum = new Scanner(System.in);
                    int useracNum= acNum.nextInt();
                    char kindOf = ' ';
                    int saleSum = 0;
                    int amountA = 2;
                    int amountB = 3;
                    int amountC = 10;
                    int amountD = 20;
                    if (useracNum == 2 || useracNum == 3){
                        if (userMoney < 100){
                            isAc = false;
                        }
                    }else if (useracNum == 4 || useracNum == 5){
                        if (userMoney < 200){
                            isAc = false;
                        }
                    }
                    if (isAc) {
                        switch (useracNum) {
                            case 1:
                                saleSum = userMoney + amountA;
                                kindOf = 'A';
                                break;
                            case 2:
                                saleSum = userMoney + amountB;
                                kindOf = 'B';
                                break;
                            case 3:
                                saleSum = userMoney + amountC;
                                kindOf = 'C';
                                break;
                            case 4:
                                saleSum = userMoney + amountC;
                                kindOf = 'D';
                                break;
                            case 5:
                                saleSum = userMoney + amountD;
                                kindOf = 'E';
                                break;
                        }
                        isRepeat = false;
                        System.out.println("您本次消费的金额为" + saleSum + "您成功换购了" + kindOf + "产品");
                    } else {
                        System.out.println("您的消费金额不足以参加该活动,请重新选择活动编号");
                    }
            }while (isRepeat);
        }
    }
}
